﻿#ifndef IMAGE_H
#define IMAGE_H

#pragma pack(push,1)
#pragma pack(pop)
#include<Windows.h>
class Image
{
public:
	Image() {}
	Image(int h, int w);
	Image(int h, int w, unsigned char val); 
	Image(const char* ImageName); 
	Image(unsigned char* m, int rows, int cols); 
	Image(unsigned char m[][100], int rows);
	Image(unsigned char** m, int h, int w); 
	Image(Image& im); 
	~Image(); 
	void create(int h, int w);
	void ReadBMP(const char* filename); 
	void WriteBMP(const char* filename); 
	void WriteBMP(const char* filename, unsigned char** data);
	void WriteBMP(const char* filename, unsigned char** data,BITMAPFILEHEADER bmpfileheader, BITMAPINFOHEADER bitmapinfoheader);
	void GreyBMP(const char* filename);
	void ReadText(const char* filename); 
	void WriteText(const char* filename); 
	unsigned char& At(int row, int col);
	void Set(int row, int col, unsigned char value); 
	void Set(unsigned char value); 
	void Flip(int code); 
	void Resize(int code); 
	void Cut(int x1, int y1, int x2, int y2);
	void Rotate(int degree);
	void Mean_Variance(float& m, float& var);
	friend void Swap(Image& a, Image& b);
	void myFree(unsigned char** data, int h);
	Image& operator=(Image& val);
	void Warm(const char* ImageName);//ůɫ˾
	void cold(const char* ImageName);//ɫ˾
	void opposite(const char* ImageName);//ȡɫ
	void old(const char* ImageName);//Ƭ˾

private:
	unsigned char** data;
	int height;
	int width;
	BITMAPFILEHEADER bmpfileheader;
	BITMAPINFOHEADER bitmapinfoheader;
};

#endif
#pragma once
